<!--
 * @Author: HeAo
 * @Date: 2021-12-30 08:33:04
 * @LastEditTime: 2022-01-06 11:10:00
 * @LastEditors: HeAo
 * @Description: 
 * @FilePath: \briup-webui-1group-teamwork\am-ui\src\pages\am\monitor\PointInfo.vue
 * 别乱动！
-->
<template>
  <div class="realTime">
    <div class="content">
      <div class="left">
        <!-- 工程设备树 -->
        <el-tree
          :data="edTree"
          :props="props"
          @node-click="handleNodeClick"
        ></el-tree>
      </div>
      <div class="right">
        <div v-if="!shuJu.id" class="notice">请先选择工程下的设备</div>
        <div v-else>
          <el-col :span="24">
            <div class="engineer_header">工程信息</div></el-col
          >
          <div class="engineer_content">
            <el-form label-width="150px" size="mini">
              <el-row>
                <el-col :span="12">
                  <el-form-item label="工程编号：">
                    {{ shuJu.engineer.serial_number }}
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="工程名称：">
                    {{ shuJu.engineer.name }}
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="12">
                  <el-form-item label="工程类型：">
                    {{ shuJu.engineer.type }}
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="工程状态：">
                    {{ shuJu.engineer.status }}
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="12">
                  <el-form-item label="开始时间：">
                    {{ shuJu.engineer.begin_time | fmtTime }}
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="结束时间：">
                    {{ shuJu.engineer.end_time | fmtTime }}
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="12">
                  <el-form-item label="地址：">
                    {{ shuJu.engineer.address }}
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="工程负责人：">
                    {{ shuJu.engineer.charge_id }}
                  </el-form-item>
                </el-col>
              </el-row>
            </el-form>
          </div>
          <el-col :span="24">
            <div class="engineer_header">设备信息</div></el-col
          >
          <div class="engineer_content">
            <el-form label-width="150px" size="mini">
              <el-row>
                <el-col :span="12">
                  <el-form-item label="工程设备：">
                    {{ shuJu.serial_number }}
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="设备名称：">
                    {{ shuJu.name }}
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="12">
                  <el-form-item label="绑定状态：">
                    {{ shuJu.bind_status }}
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="在线状态：">
                    <template>
                      <el-tag
                        size="mini"
                        v-if="shuJu.online_status == 1"
                        type="success"
                        >在线</el-tag
                      >
                      <el-tag size="mini" v-else type="info">离线</el-tag>
                    </template>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-form>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { get } from "@/utils/request.js";
export default {
  data() {
    return {
      shuJu: {},
      edTree: [],
      props: {
        label: "name",
        value: "id",
      },
    };
  },
  methods: {
    //树形节点点击事件
    handleNodeClick(data) {
      // 判断用户点击的是否是设备，点击工程时不查询数据
      if (data.engineer_id) {
        this.params = {
          ...this.params,
          engineer_id: data.engineer_id,
          device_id: data.device_id,
        };
        // 调用请求设备数据的方法
        this.findDevicesByEngineer(data.id);
      }
    },
    // 查询工程设备树
    findEngineerDeviceTree() {
      get("/engineer/findEngineerDeviceTree").then((res) => {
        this.edTree = res.data;
      });
    },
    //查询当前设备绑定工程和设备详情
    findDevicesByEngineer(id) {
      get("/device/findDeviceDetail", { id }).then((res) => {
        this.shuJu = res.data;
      });
    },
  },
  created() {
    //查询工程设备树
    this.findEngineerDeviceTree();
  },
};
</script>
<style scoped>
.content {
  display: flex;
  text-align: center;
  font-size: 30px;
  color: #999;
}
.left {
  width: 30%;
  border-right: 1px solid #b9b7b7;
  padding-right: 20px;
  margin-right: 20px;
}
.right {
  width: 70%;
}
.engineer_header {
  height: 42px;
  line-height: 42px;
  background: #ededed;
  color: rgb(100, 99, 99);
  font-size: 18px;
  border-radius: 3px;
  padding-left: 1em;
}
</style>